package com.examples

import com.example.zjx8969.myapplication.beans.Student

object ServiceHolder {
    val map = HashMap<String, Student>()

    inline fun <reified T> getServiceAndRun(path: String, body: T.() -> Unit) {
        val type = map[path]
        if (type is T) {
            body.invoke(type)
        }
    }

    fun <T> getService(path: String): T? {
        return map[path] as T?

    }
}

fun main() {
    ServiceHolder.map["abc"] = Student("abc", 12)
    ServiceHolder.getServiceAndRun<Student>("abc") {
        println(toString())
    }
}

